package com.dzl.supplier;

import com.dzl.base.controller.BaseController;
import com.dzl.constant.CommonConstants;
import com.dzl.supplier.pojo.query.WelfareSupplierBrandQuery;
import com.dzl.supplier.service.WelfareSupplierBrandService;
import com.dzl.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 供应商和品牌的关联关系  - 控制层
 * @author WangJian
 * @date 2021/7/12 0012
 */
@RestController
@RequestMapping("supplierBrand")
public class WelfareSupplierBrandController extends BaseController {

    @Autowired
    private WelfareSupplierBrandService welfareSupplierBrandService;

    /**
     * 根据品牌ID查供应商信息，根据供应商ID查品牌信息
     * @date 2021/7/12 0012 11:27
     * @author wangjian
     * @param welfareSupplierBrand 关联筛选的条件
     * @return com.dzl.util.JsonResult<com.dzl.supplierBrand.pojo.vo.WelfareSupplierBrandVo>
     */
    @GetMapping("/querySupplierAndBrand")
    public JsonResult<Map<String, Object>> querySupplierAndBrand(WelfareSupplierBrandQuery welfareSupplierBrand){
        welfareSupplierBrand.setEnterpriseId(getAdminInfo().getEnterpriseId());
        if(welfareSupplierBrand.getContainFulitu()==null){
            welfareSupplierBrand.setContainFulitu(CommonConstants.YES);
        }
        return JsonResult.success(welfareSupplierBrandService.selectSupplierBrandVo(welfareSupplierBrand));
    }


}
